package watcherPattern;

import java.util.Observable;
import java.util.Observer;

public class SecondObserver implements Observer {

	Observable observable;

	public SecondObserver(Observable observable) {
		this.observable = observable;
		observable.addObserver(this);
	}

	@Override
	public void update(Observable o, Object arg) {
		if (o instanceof WeatherData) {
			WeatherData weatherData = (WeatherData) o;
			int temprature = weatherData.getTemperature();
			int rain = weatherData.getRain();
			display(temprature, rain);
		}
	}

	private void display(int temprature, int rain) {

		System.out.println("====In Second Observer=====");
		System.out.println("Temprature: " + temprature);
		System.out.println("Rain: " + rain);
	}

}
